package com.example.mykotlin.base.util

import jakarta.validation.Constraint
import jakarta.validation.Payload
import java.lang.annotation.Repeatable
import kotlin.reflect.KClass

@MustBeDocumented
@Target(
    AnnotationTarget.FUNCTION,
    AnnotationTarget.FIELD,
    AnnotationTarget.ANNOTATION_CLASS,
    AnnotationTarget.CONSTRUCTOR,
    AnnotationTarget.TYPE,
    AnnotationTarget.VALUE_PARAMETER,
    AnnotationTarget.TYPE_PARAMETER,
    AnnotationTarget.PROPERTY,
    AnnotationTarget.PROPERTY_GETTER,
    AnnotationTarget.PROPERTY_SETTER
)
@Retention
@Repeatable(Ev.ListEve::class) // 允许在同一元素上多次使用该注解
@Constraint(validatedBy = [EnumValidator::class])
annotation class Ev(
    val enumClass: KClass<*>,

    val message: String = "值不正确",

    val method: String = "value",

    val groups: Array<KClass<*>> = [],

    val payload: Array<KClass<out Payload>> = []

) {

    @MustBeDocumented
    @Target(
        AnnotationTarget.FUNCTION,
        AnnotationTarget.PROPERTY_GETTER,
        AnnotationTarget.PROPERTY_SETTER,
        AnnotationTarget.FIELD,
        AnnotationTarget.ANNOTATION_CLASS,
        AnnotationTarget.CONSTRUCTOR,
        AnnotationTarget.VALUE_PARAMETER,
        AnnotationTarget.CLASS,
        AnnotationTarget.TYPE,
        AnnotationTarget.TYPE_PARAMETER
    )
    @Retention(
        AnnotationRetention.RUNTIME
    )
    annotation class ListEve(vararg val value: Ev)
}
